43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
def picture(world, Xs: range, Ys: range) -> str:world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long>
return '\n'.join(row(y) for y in Ys)world=<too long>
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)
return '\n'.join(row(y) for y in Ys)
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=0 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=0 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0
.world=<too long> y=0 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=0
.world=<too long> y=0 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=1
.world=<too long> y=0 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=2
.world=<too long> y=0 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=3
.world=<too long> y=0 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=4
.world=<too long> y=0 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=5
@world=<too long> y=0 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=6
.world=<too long> y=0 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=7
@world=<too long> y=0 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=8
.world=<too long> y=0 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=9
.world=<too long> y=0 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=10
.world=<too long> y=0 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=11
.world=<too long> y=0 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=12
.world=<too long> y=0 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=13
.world=<too long> y=0 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=0 x=14
Noneworld=<too long> y=0 x=14
. . . . . . @ . @ . . . . . .y=0 world=<too long>
. . . . . . @ . @ . . . . . .y=0
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=0
return '\n'.join(row(y) for y in Ys)y=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=1 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=1 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1
.world=<too long> y=1 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=0
.world=<too long> y=1 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=1
.world=<too long> y=1 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=2
@world=<too long> y=1 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=3
.world=<too long> y=1 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=4
.world=<too long> y=1 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=5
@world=<too long> y=1 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=6
.world=<too long> y=1 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=7
.world=<too long> y=1 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=8
.world=<too long> y=1 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=9
.world=<too long> y=1 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=10
.world=<too long> y=1 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=11
.world=<too long> y=1 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=12
.world=<too long> y=1 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=13
.world=<too long> y=1 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=1 x=14
Noneworld=<too long> y=1 x=14
. . . @ . . @ . . . . . . . .y=1 world=<too long>
. . . @ . . @ . . . . . . . .y=1
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=1
return '\n'.join(row(y) for y in Ys)y=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=2 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=2 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2
.world=<too long> y=2 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=0
.world=<too long> y=2 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=1
@world=<too long> y=2 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=2
@world=<too long> y=2 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=3
@world=<too long> y=2 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=4
.world=<too long> y=2 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=5
.world=<too long> y=2 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=6
.world=<too long> y=2 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=7
@world=<too long> y=2 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=8
.world=<too long> y=2 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=9
.world=<too long> y=2 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=10
.world=<too long> y=2 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=11
.world=<too long> y=2 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=12
.world=<too long> y=2 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=13
.world=<too long> y=2 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=2 x=14
Noneworld=<too long> y=2 x=14
. . @ @ @ . . . @ . . . . . .y=2 world=<too long>
. . @ @ @ . . . @ . . . . . .y=2
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=2
return '\n'.join(row(y) for y in Ys)y=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=3 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=3 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3
@world=<too long> y=3 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=0
.world=<too long> y=3 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=1
@world=<too long> y=3 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=2
.world=<too long> y=3 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=3
.world=<too long> y=3 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=4
.world=<too long> y=3 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=5
.world=<too long> y=3 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=6
.world=<too long> y=3 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=7
.world=<too long> y=3 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=8
@world=<too long> y=3 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=9
.world=<too long> y=3 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=10
.world=<too long> y=3 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=11
.world=<too long> y=3 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=12
.world=<too long> y=3 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=13
.world=<too long> y=3 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=3 x=14
Noneworld=<too long> y=3 x=14
@ . @ . . . . . . @ . . . . .y=3 world=<too long>
@ . @ . . . . . . @ . . . . .y=3
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=3
return '\n'.join(row(y) for y in Ys)y=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=4 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=4 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4
.world=<too long> y=4 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=0
.world=<too long> y=4 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=1
.world=<too long> y=4 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=2
.world=<too long> y=4 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=3
.world=<too long> y=4 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=4
@world=<too long> y=4 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=5
.world=<too long> y=4 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=6
.world=<too long> y=4 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=7
.world=<too long> y=4 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=8
.world=<too long> y=4 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=9
.world=<too long> y=4 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=10
.world=<too long> y=4 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=11
.world=<too long> y=4 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=12
.world=<too long> y=4 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=13
.world=<too long> y=4 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=4 x=14
Noneworld=<too long> y=4 x=14
. . . . . @ . . . . . . . . .y=4 world=<too long>
. . . . . @ . . . . . . . . .y=4
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=4
return '\n'.join(row(y) for y in Ys)y=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=5 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=5 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5
.world=<too long> y=5 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=0
.world=<too long> y=5 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=1
.world=<too long> y=5 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=2
@world=<too long> y=5 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=3
.world=<too long> y=5 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=4
.world=<too long> y=5 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=5
.world=<too long> y=5 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=6
@world=<too long> y=5 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=7
.world=<too long> y=5 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=8
.world=<too long> y=5 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=9
.world=<too long> y=5 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=10
.world=<too long> y=5 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=11
.world=<too long> y=5 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=12
.world=<too long> y=5 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=13
.world=<too long> y=5 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=5 x=14
Noneworld=<too long> y=5 x=14
. . . @ . . . @ . . . . . . .y=5 world=<too long>
. . . @ . . . @ . . . . . . .y=5
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=5
return '\n'.join(row(y) for y in Ys)y=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=6 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=6 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6
.world=<too long> y=6 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=0
@world=<too long> y=6 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=1
@world=<too long> y=6 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=2
.world=<too long> y=6 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=3
.world=<too long> y=6 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=4
.world=<too long> y=6 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=5
.world=<too long> y=6 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=6
.world=<too long> y=6 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=7
@world=<too long> y=6 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=8
.world=<too long> y=6 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=9
.world=<too long> y=6 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=10
.world=<too long> y=6 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=11
.world=<too long> y=6 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=12
.world=<too long> y=6 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=13
.world=<too long> y=6 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=6 x=14
Noneworld=<too long> y=6 x=14
. @ @ . . . . . @ . . . . . .y=6 world=<too long>
. @ @ . . . . . @ . . . . . .y=6
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=6
return '\n'.join(row(y) for y in Ys)y=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=7 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=7 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7
.world=<too long> y=7 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=0
.world=<too long> y=7 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=1
.world=<too long> y=7 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=2
.world=<too long> y=7 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=3
.world=<too long> y=7 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=4
.world=<too long> y=7 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=5
.world=<too long> y=7 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=6
.world=<too long> y=7 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=7
.world=<too long> y=7 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=8
.world=<too long> y=7 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=9
.world=<too long> y=7 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=10
.world=<too long> y=7 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=11
.world=<too long> y=7 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=12
.world=<too long> y=7 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=13
.world=<too long> y=7 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=7 x=14
Noneworld=<too long> y=7 x=14
. . . . . . . . . . . . . . .y=7 world=<too long>
. . . . . . . . . . . . . . .y=7
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=7
return '\n'.join(row(y) for y in Ys)y=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=8 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=8 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8
.world=<too long> y=8 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=0
.world=<too long> y=8 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=1
.world=<too long> y=8 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=2
.world=<too long> y=8 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=3
.world=<too long> y=8 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=4
.world=<too long> y=8 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=5
.world=<too long> y=8 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=6
.world=<too long> y=8 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=7
@world=<too long> y=8 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=8
.world=<too long> y=8 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=9
.world=<too long> y=8 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=10
.world=<too long> y=8 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=11
.world=<too long> y=8 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=12
.world=<too long> y=8 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=13
.world=<too long> y=8 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=8 x=14
Noneworld=<too long> y=8 x=14
. . . . . . . . @ . . . . . .y=8 world=<too long>
. . . . . . . . @ . . . . . .y=8
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=8
return '\n'.join(row(y) for y in Ys)y=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=9 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=9 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9
.world=<too long> y=9 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=0
.world=<too long> y=9 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=1
.world=<too long> y=9 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=2
.world=<too long> y=9 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=3
.world=<too long> y=9 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=4
.world=<too long> y=9 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=5
.world=<too long> y=9 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=6
@world=<too long> y=9 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=7
.world=<too long> y=9 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=8
.world=<too long> y=9 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=9
.world=<too long> y=9 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=10
.world=<too long> y=9 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=11
.world=<too long> y=9 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=12
.world=<too long> y=9 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=13
.world=<too long> y=9 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=9 x=14
Noneworld=<too long> y=9 x=14
. . . . . . . @ . . . . . . .y=9 world=<too long>
. . . . . . . @ . . . . . . .y=9
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=9
return '\n'.join(row(y) for y in Ys)y=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=10 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=10 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10
.world=<too long> y=10 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=0
.world=<too long> y=10 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=1
.world=<too long> y=10 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=2
.world=<too long> y=10 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=3
.world=<too long> y=10 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=4
.world=<too long> y=10 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=5
.world=<too long> y=10 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=6
.world=<too long> y=10 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=7
.world=<too long> y=10 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=8
.world=<too long> y=10 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=9
.world=<too long> y=10 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=10
.world=<too long> y=10 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=11
.world=<too long> y=10 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=12
.world=<too long> y=10 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=13
.world=<too long> y=10 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=10 x=14
Noneworld=<too long> y=10 x=14
. . . . . . . . . . . . . . .y=10 world=<too long>
. . . . . . . . . . . . . . .y=10
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=10
return '\n'.join(row(y) for y in Ys)y=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=11 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=11 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11
.world=<too long> y=11 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=0
.world=<too long> y=11 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=1
.world=<too long> y=11 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=2
.world=<too long> y=11 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=3
.world=<too long> y=11 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=4
.world=<too long> y=11 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=5
.world=<too long> y=11 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=6
.world=<too long> y=11 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=7
.world=<too long> y=11 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=8
.world=<too long> y=11 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=9
.world=<too long> y=11 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=10
.world=<too long> y=11 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=11
.world=<too long> y=11 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=12
.world=<too long> y=11 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=13
.world=<too long> y=11 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=11 x=14
Noneworld=<too long> y=11 x=14
. . . . . . . . . . . . . . .y=11 world=<too long>
. . . . . . . . . . . . . . .y=11
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=11
return '\n'.join(row(y) for y in Ys)y=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=12 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=12 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12
.world=<too long> y=12 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=0
.world=<too long> y=12 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=1
.world=<too long> y=12 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=2
.world=<too long> y=12 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=3
.world=<too long> y=12 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=4
.world=<too long> y=12 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=5
.world=<too long> y=12 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=6
.world=<too long> y=12 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=7
.world=<too long> y=12 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=8
.world=<too long> y=12 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=9
.world=<too long> y=12 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=10
.world=<too long> y=12 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=11
.world=<too long> y=12 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=12
.world=<too long> y=12 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=13
.world=<too long> y=12 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=12 x=14
Noneworld=<too long> y=12 x=14
. . . . . . . . . . . . . . .y=12 world=<too long>
. . . . . . . . . . . . . . .y=12
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=12
return '\n'.join(row(y) for y in Ys)y=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=13 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=13 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13
.world=<too long> y=13 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=0
.world=<too long> y=13 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=1
.world=<too long> y=13 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=2
.world=<too long> y=13 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=3
.world=<too long> y=13 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=4
.world=<too long> y=13 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=5
.world=<too long> y=13 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=6
.world=<too long> y=13 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=7
.world=<too long> y=13 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=8
.world=<too long> y=13 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=9
.world=<too long> y=13 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=10
.world=<too long> y=13 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=11
.world=<too long> y=13 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=12
.world=<too long> y=13 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=13
.world=<too long> y=13 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=13 x=14
Noneworld=<too long> y=13 x=14
. . . . . . . . . . . . . . .y=13 world=<too long>
. . . . . . . . . . . . . . .y=13
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=13
return '\n'.join(row(y) for y in Ys)y=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=14 world=<too long>
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)y=14 world=<too long>
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14
.world=<too long> y=14 x=0
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=0
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=0
.world=<too long> y=14 x=1
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=1
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=1
.world=<too long> y=14 x=2
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=2
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=2
.world=<too long> y=14 x=3
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=3
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=3
.world=<too long> y=14 x=4
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=4
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=4
.world=<too long> y=14 x=5
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=5
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=5
.world=<too long> y=14 x=6
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=6
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=6
.world=<too long> y=14 x=7
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=7
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=7
.world=<too long> y=14 x=8
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=8
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=8
.world=<too long> y=14 x=9
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=9
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=9
.world=<too long> y=14 x=10
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=10
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=10
.world=<too long> y=14 x=11
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=11
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=11
.world=<too long> y=14 x=12
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=12
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=12
.world=<too long> y=14 x=13
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=13
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=13
.world=<too long> y=14 x=14
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=14
def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)world=<too long> y=14 x=14
Noneworld=<too long> y=14 x=14
. . . . . . . . . . . . . . .y=14 world=<too long>
. . . . . . . . . . . . . . .y=14
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
103:
104: Generation 2
105: . . . . . . . . . . . . . . .
106: . . . . . . . . . . . . . . .
107: . . @ @ @ . . . @ . . . . . .
108: @ . . . @ . . . . @ . . . . .
109: . . @ @ . . . @ @ @ . . . . .
110: . . @ . . . . . . . . . . . .
111: @ @ . . . . . . . . . . . . .
112: . . . . . . . . . . . . . . .
113: . . . . . . . . . . . . . . .
114: . . . . . . . . . . . . . . .
115: . . . . . . . . . . . . . . .
116: . . . . . . . . . . . . . . .
117: . . . . . . . . . . . . . . .
118: . . . . . . . . . . . . . . .
119: . . . . . . . . . . . . . . .
return '\n'.join(row(y) for y in Ys)y=14
return '\n'.join(row(y) for y in Ys)y=14
Noney=14
. . . . . . @ . @ . . . . . . . . . @ . . @ . . . . . . . . . . @ @ @ . . . @ . . . . . . @ . @ . . . . . . @ . . . . . . . . . . @ . . . . . . . . . . . . @ . . . @ . . . . . . . . @ @ . . . . . @ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @ . . . . . . . . . . . . . @ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .world=<too long>
17: alive_cells = next_generation(alive_cells)
18:
19:
20: def next_generation(alive_cells):
21: return {
22: cell
23: for cell, count in neighbor_counts(alive_cells).items()
24: if count == 3 or (cell in alive_cells and count == 2)
25: }
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
def next_generation(alive_cells):alive_cells=<too long>
return { alive_cells=<too long>
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long>
24: if count == 3 or (cell in alive_cells and count == 2)
25: }
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
def neighbor_counts(alive_cells):alive_cells=<too long>
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))alive_cells=<too long>
584: # http://code.activestate.com/recipes/259174/
585: # Knuth, TAOCP Vol. II section 4.6.3
586:
587: def __init__(self, iterable=None, /, **kwds):
588: '''Create a new, empty Counter object. And if given, count elements
589: from an input iterable. Or, initialize the count from another mapping
590: of elements to their counts.
591:
592: >>> c = Counter() # a new, empty counter
593: >>> c = Counter('gallahad') # a new counter from an iterable
594: >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping
595: >>> c = Counter(a=4, b=2) # a new counter from keyword args
596:
597: '''
598: super().__init__()
599: self.update(iterable, **kwds)
600:
601: def __missing__(self, key):
602: 'The count of elements not in the Counter is zero.'
603: # Needed so that self[missing_item] does not raise KeyError
604: return 0
605:
606: def total(self):
607: 'Sum of the counts'
608: return sum(self.values())
609:
610: def most_common(self, n=None):
611: '''List the n most common elements and their counts from the most
612: common to the least. If n is None, then list all element counts.
613:
614: >>> Counter('abracadabra').most_common(3)
615: [('a', 5), ('b', 2), ('r', 2)]
616:
617: '''
618: # Emulate Bag.sortedByCount from Smalltalk
619: if n is None:
620: return sorted(self.items(), key=_itemgetter(1), reverse=True)
621:
622: # Lazy import to speedup Python startup time
623: import heapq
624: return heapq.nlargest(n, self.items(), key=_itemgetter(1))
625:
626: def elements(self):
627: '''Iterator over elements repeating each as many times as its count.
628:
629: >>> c = Counter('ABCABC')
630: >>> sorted(c.elements())
631: ['A', 'A', 'B', 'B', 'C', 'C']
632:
633: # Knuth's example for prime factors of 1836: 2**2 * 3**3 * 17**1
634: >>> import math
635: >>> prime_factors = Counter({2: 2, 3: 3, 17: 1})
636: >>> math.prod(prime_factors.elements())
637: 1836
638:
639: Note, if an element's count has been set to zero or is a negative
640: number, elements() will ignore it.
641:
642: '''
643: # Emulate Bag.do from Smalltalk and Multiset.begin from C++.
644: return _chain.from_iterable(_starmap(_repeat, self.items()))
645:
646: # Override dict methods where necessary
647:
648: @classmethod
649: def fromkeys(cls, iterable, v=None):
650: # There is no equivalent method for counters because the semantics
651: # would be ambiguous in cases such as Counter.fromkeys('aaabbc', v=2).
652: # Initializing counters to zero values isn't necessary because zero
653: # is already the default value for counter lookups. Initializing
654: # to one is easily accomplished with Counter(set(iterable)). For
655: # more exotic cases, create a dictionary first using a dictionary
656: # comprehension or dict.fromkeys().
657: raise NotImplementedError(
def __init__(self, iterable=None, /, **kwds):self=Counter() kwds={}
super().__init__()self=Counter() kwds={}
self.update(iterable, **kwds)self=Counter() kwds={}
657: raise NotImplementedError(
658: 'Counter.fromkeys() is undefined. Use Counter(iterable) instead.')
659:
660: def update(self, iterable=None, /, **kwds):
661: '''Like dict.update() but add counts instead of replacing them.
662:
663: Source can be an iterable, a dictionary, or another Counter instance.
664:
665: >>> c = Counter('which')
666: >>> c.update('witch') # add elements from another iterable
667: >>> d = Counter('watch')
668: >>> c.update(d) # add elements from another counter
669: >>> c['h'] # four 'h' in which, witch, and watch
670: 4
671:
672: '''
673: # The regular dict.update() operation makes no sense here because the
674: # replace behavior results in the some of original untouched counts
675: # being mixed-in with all of the other counts for a mismash that
676: # doesn't have a straight-forward interpretation in most counting
677: # contexts. Instead, we implement straight-addition. Both the inputs
678: # and outputs are allowed to contain zero and negative counts.
679:
680: if iterable is not None:
681: if isinstance(iterable, _collections_abc.Mapping):
682: if self:
683: self_get = self.get
684: for elem, count in iterable.items():
685: self[elem] = count + self_get(elem, 0)
686: else:
687: # fast path when counter is empty
688: super().update(iterable)
689: else:
690: _count_elements(self, iterable)
691: if kwds:
692: self.update(kwds)
693:
694: def subtract(self, iterable=None, /, **kwds):
695: '''Like dict.update() but subtracts counts instead of replacing them.
696: Counts can be reduced below zero. Both the inputs and outputs are
697: allowed to contain zero and negative counts.
698:
699: Source can be an iterable, a dictionary, or another Counter instance.
700:
701: >>> c = Counter('which')
702: >>> c.subtract('witch') # subtract elements from another iterable
703: >>> c.subtract(Counter('watch')) # subtract elements from another counter
704: >>> c['h'] # 2 in which, minus 1 in witch, minus 1 in watch
705: 0
706: >>> c['w'] # 1 in which, minus 1 in witch, minus 1 in watch
707: -1
708:
709: '''
710: if iterable is not None:
711: self_get = self.get
712: if isinstance(iterable, _collections_abc.Mapping):
713: for elem, count in iterable.items():
714: self[elem] = self_get(elem, 0) - count
715: else:
716: for elem in iterable:
717: self[elem] = self_get(elem, 0) - 1
718: if kwds:
719: self.subtract(kwds)
720:
721: def copy(self):
722: 'Return a shallow copy.'
723: return self.__class__(self)
724:
725: def __reduce__(self):
726: return self.__class__, (dict(self),)
727:
728: def __delitem__(self, elem):
729: 'Like dict.__delitem__() but does not raise KeyError for missing values.'
730: if elem in self:
def update(self, iterable=None, /, **kwds):self=Counter() kwds={}
if iterable is not None:self=Counter() kwds={}
if isinstance(iterable, _collections_abc.Mapping):self=Counter() kwds={}
NotImplemented
NotImplemented
NotImplemented
False
NotImplemented
False
NotImplemented
False
NotImplemented
False
NotImplemented
False
False
NotImplemented
False
False
False
_count_elements(self, iterable)self=Counter() kwds={}
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(3, 1)
return { cell=(3, 1)
for dx in [-1, 0, 1]cell=(3, 1)
return { cell=(3, 1)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(3, 1)
return { cell=(3, 1)
for dx in [-1, 0, 1]cell=(3, 1)
for dy in [-1, 0, 1]cell=(3, 1) dx=-1
return { cell=(3, 1) dx=-1
for dy in [-1, 0, 1]cell=(3, 1) dx=-1
if (dx, dy) != (0, 0)cell=(3, 1) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(3, 1) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(3, 1) dx=-1 dy=-1
return { cell=(3, 1) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(3, 1) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(3, 1) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(3, 1) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(3, 1) dx=-1 dy=0
return { cell=(3, 1) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(3, 1) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(3, 1) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(3, 1) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(3, 1) dx=-1 dy=1
return { cell=(3, 1) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(3, 1) dx=-1 dy=1
return { cell=(3, 1) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(3, 1) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(3, 1) dx=0 dy=1
return { cell=(3, 1) dx=0 dy=1
for dy in [-1, 0, 1]cell=(3, 1) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(3, 1) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(3, 1) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(3, 1) dx=0 dy=-1
return { cell=(3, 1) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(3, 1) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(3, 1) dx=0 dy=0
return { cell=(3, 1) dx=0 dy=0
for dy in [-1, 0, 1]cell=(3, 1) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(3, 1) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(3, 1) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(3, 1) dx=0 dy=1
return { cell=(3, 1) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(3, 1) dx=0 dy=1
return { cell=(3, 1) dx=0 dy=1
for dx in [-1, 0, 1]cell=(3, 1) dx=0 dy=1
for dy in [-1, 0, 1]cell=(3, 1) dx=1 dy=1
return { cell=(3, 1) dx=1 dy=1
for dy in [-1, 0, 1]cell=(3, 1) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(3, 1) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(3, 1) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(3, 1) dx=1 dy=-1
return { cell=(3, 1) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(3, 1) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(3, 1) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(3, 1) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(3, 1) dx=1 dy=0
return { cell=(3, 1) dx=1 dy=0
for dy in [-1, 0, 1]cell=(3, 1) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(3, 1) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(3, 1) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(3, 1) dx=1 dy=1
return { cell=(3, 1) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(3, 1) dx=1 dy=1
return { cell=(3, 1) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(3, 1) dx=1 dy=1
{(4, 0), (2, 1), (2, 0), (4, 2), (3, 0), (2, 2), (3, 2), (4, 1)} cell=(3, 1) dx=1 dy=1
{(4, 0), (2, 1), (2, 0), (4, 2), (3, 0), (2, 2), (3, 2), (4, 1)} cell=(3, 1)
(4, 0)cell=(3, 1) neighbor=(4, 0)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(4, 0)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(4, 0)
(2, 1)cell=(3, 1) neighbor=(2, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(2, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(2, 1)
(2, 0)cell=(3, 1) neighbor=(2, 0)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(2, 0)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(2, 0)
(4, 2)cell=(3, 1) neighbor=(4, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(4, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(4, 2)
(3, 0)cell=(3, 1) neighbor=(3, 0)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(3, 0)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(3, 0)
(2, 2)cell=(3, 1) neighbor=(2, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(2, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(2, 2)
(3, 2)cell=(3, 1) neighbor=(3, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(3, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(3, 2)
(4, 1)cell=(3, 1) neighbor=(4, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(4, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(4, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 1) neighbor=(4, 1)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(5, 4)
return { cell=(5, 4)
for dx in [-1, 0, 1]cell=(5, 4)
return { cell=(5, 4)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(5, 4)
return { cell=(5, 4)
for dx in [-1, 0, 1]cell=(5, 4)
for dy in [-1, 0, 1]cell=(5, 4) dx=-1
return { cell=(5, 4) dx=-1
for dy in [-1, 0, 1]cell=(5, 4) dx=-1
if (dx, dy) != (0, 0)cell=(5, 4) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(5, 4) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(5, 4) dx=-1 dy=-1
return { cell=(5, 4) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(5, 4) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(5, 4) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(5, 4) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(5, 4) dx=-1 dy=0
return { cell=(5, 4) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(5, 4) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(5, 4) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(5, 4) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(5, 4) dx=-1 dy=1
return { cell=(5, 4) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(5, 4) dx=-1 dy=1
return { cell=(5, 4) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(5, 4) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(5, 4) dx=0 dy=1
return { cell=(5, 4) dx=0 dy=1
for dy in [-1, 0, 1]cell=(5, 4) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(5, 4) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(5, 4) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(5, 4) dx=0 dy=-1
return { cell=(5, 4) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(5, 4) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(5, 4) dx=0 dy=0
return { cell=(5, 4) dx=0 dy=0
for dy in [-1, 0, 1]cell=(5, 4) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(5, 4) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(5, 4) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(5, 4) dx=0 dy=1
return { cell=(5, 4) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(5, 4) dx=0 dy=1
return { cell=(5, 4) dx=0 dy=1
for dx in [-1, 0, 1]cell=(5, 4) dx=0 dy=1
for dy in [-1, 0, 1]cell=(5, 4) dx=1 dy=1
return { cell=(5, 4) dx=1 dy=1
for dy in [-1, 0, 1]cell=(5, 4) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(5, 4) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(5, 4) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(5, 4) dx=1 dy=-1
return { cell=(5, 4) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(5, 4) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(5, 4) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(5, 4) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(5, 4) dx=1 dy=0
return { cell=(5, 4) dx=1 dy=0
for dy in [-1, 0, 1]cell=(5, 4) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(5, 4) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(5, 4) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(5, 4) dx=1 dy=1
return { cell=(5, 4) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(5, 4) dx=1 dy=1
return { cell=(5, 4) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(5, 4) dx=1 dy=1
{(4, 4), (5, 5), (6, 5), (4, 3), (6, 4), (4, 5), (5, 3), (6, 3)} cell=(5, 4) dx=1 dy=1
{(4, 4), (5, 5), (6, 5), (4, 3), (6, 4), (4, 5), (5, 3), (6, 3)} cell=(5, 4)
(4, 4)cell=(5, 4) neighbor=(4, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(4, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(4, 4)
(5, 5)cell=(5, 4) neighbor=(5, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(5, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(5, 5)
(6, 5)cell=(5, 4) neighbor=(6, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(6, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(6, 5)
(4, 3)cell=(5, 4) neighbor=(4, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(4, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(4, 3)
(6, 4)cell=(5, 4) neighbor=(6, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(6, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(6, 4)
(4, 5)cell=(5, 4) neighbor=(4, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(4, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(4, 5)
(5, 3)cell=(5, 4) neighbor=(5, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(5, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(5, 3)
(6, 3)cell=(5, 4) neighbor=(6, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(6, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(6, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(5, 4) neighbor=(6, 3)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(8, 0)
return { cell=(8, 0)
for dx in [-1, 0, 1]cell=(8, 0)
return { cell=(8, 0)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(8, 0)
return { cell=(8, 0)
for dx in [-1, 0, 1]cell=(8, 0)
for dy in [-1, 0, 1]cell=(8, 0) dx=-1
return { cell=(8, 0) dx=-1
for dy in [-1, 0, 1]cell=(8, 0) dx=-1
if (dx, dy) != (0, 0)cell=(8, 0) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(8, 0) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 0) dx=-1 dy=-1
return { cell=(8, 0) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(8, 0) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 0) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(8, 0) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(8, 0) dx=-1 dy=0
return { cell=(8, 0) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(8, 0) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(8, 0) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(8, 0) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(8, 0) dx=-1 dy=1
return { cell=(8, 0) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(8, 0) dx=-1 dy=1
return { cell=(8, 0) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(8, 0) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(8, 0) dx=0 dy=1
return { cell=(8, 0) dx=0 dy=1
for dy in [-1, 0, 1]cell=(8, 0) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(8, 0) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(8, 0) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(8, 0) dx=0 dy=-1
return { cell=(8, 0) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(8, 0) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(8, 0) dx=0 dy=0
return { cell=(8, 0) dx=0 dy=0
for dy in [-1, 0, 1]cell=(8, 0) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(8, 0) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(8, 0) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(8, 0) dx=0 dy=1
return { cell=(8, 0) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(8, 0) dx=0 dy=1
return { cell=(8, 0) dx=0 dy=1
for dx in [-1, 0, 1]cell=(8, 0) dx=0 dy=1
for dy in [-1, 0, 1]cell=(8, 0) dx=1 dy=1
return { cell=(8, 0) dx=1 dy=1
for dy in [-1, 0, 1]cell=(8, 0) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 0) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(8, 0) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 0) dx=1 dy=-1
return { cell=(8, 0) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(8, 0) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 0) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(8, 0) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(8, 0) dx=1 dy=0
return { cell=(8, 0) dx=1 dy=0
for dy in [-1, 0, 1]cell=(8, 0) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(8, 0) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(8, 0) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 0) dx=1 dy=1
return { cell=(8, 0) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 0) dx=1 dy=1
return { cell=(8, 0) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 0) dx=1 dy=1
{(7, -1), (9, 0), (8, -1), (7, 1), (8, 1), (7, 0), (9, -1), (9, 1)} cell=(8, 0) dx=1 dy=1
{(7, -1), (9, 0), (8, -1), (7, 1), (8, 1), (7, 0), (9, -1), (9, 1)} cell=(8, 0)
(7, -1)cell=(8, 0) neighbor=(7, -1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(7, -1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(7, -1)
(9, 0)cell=(8, 0) neighbor=(9, 0)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(9, 0)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(9, 0)
(8, -1)cell=(8, 0) neighbor=(8, -1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(8, -1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(8, -1)
(7, 1)cell=(8, 0) neighbor=(7, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(7, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(7, 1)
(8, 1)cell=(8, 0) neighbor=(8, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(8, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(8, 1)
(7, 0)cell=(8, 0) neighbor=(7, 0)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(7, 0)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(7, 0)
(9, -1)cell=(8, 0) neighbor=(9, -1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(9, -1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(9, -1)
(9, 1)cell=(8, 0) neighbor=(9, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(9, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(9, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 0) neighbor=(9, 1)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(8, 6)
return { cell=(8, 6)
for dx in [-1, 0, 1]cell=(8, 6)
return { cell=(8, 6)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(8, 6)
return { cell=(8, 6)
for dx in [-1, 0, 1]cell=(8, 6)
for dy in [-1, 0, 1]cell=(8, 6) dx=-1
return { cell=(8, 6) dx=-1
for dy in [-1, 0, 1]cell=(8, 6) dx=-1
if (dx, dy) != (0, 0)cell=(8, 6) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(8, 6) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 6) dx=-1 dy=-1
return { cell=(8, 6) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(8, 6) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 6) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(8, 6) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(8, 6) dx=-1 dy=0
return { cell=(8, 6) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(8, 6) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(8, 6) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(8, 6) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(8, 6) dx=-1 dy=1
return { cell=(8, 6) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(8, 6) dx=-1 dy=1
return { cell=(8, 6) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(8, 6) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(8, 6) dx=0 dy=1
return { cell=(8, 6) dx=0 dy=1
for dy in [-1, 0, 1]cell=(8, 6) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(8, 6) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(8, 6) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(8, 6) dx=0 dy=-1
return { cell=(8, 6) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(8, 6) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(8, 6) dx=0 dy=0
return { cell=(8, 6) dx=0 dy=0
for dy in [-1, 0, 1]cell=(8, 6) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(8, 6) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(8, 6) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(8, 6) dx=0 dy=1
return { cell=(8, 6) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(8, 6) dx=0 dy=1
return { cell=(8, 6) dx=0 dy=1
for dx in [-1, 0, 1]cell=(8, 6) dx=0 dy=1
for dy in [-1, 0, 1]cell=(8, 6) dx=1 dy=1
return { cell=(8, 6) dx=1 dy=1
for dy in [-1, 0, 1]cell=(8, 6) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 6) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(8, 6) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 6) dx=1 dy=-1
return { cell=(8, 6) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(8, 6) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 6) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(8, 6) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(8, 6) dx=1 dy=0
return { cell=(8, 6) dx=1 dy=0
for dy in [-1, 0, 1]cell=(8, 6) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(8, 6) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(8, 6) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 6) dx=1 dy=1
return { cell=(8, 6) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 6) dx=1 dy=1
return { cell=(8, 6) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 6) dx=1 dy=1
{(7, 7), (8, 7), (9, 6), (9, 5), (7, 6), (7, 5), (9, 7), (8, 5)} cell=(8, 6) dx=1 dy=1
{(7, 7), (8, 7), (9, 6), (9, 5), (7, 6), (7, 5), (9, 7), (8, 5)} cell=(8, 6)
(7, 7)cell=(8, 6) neighbor=(7, 7)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(7, 7)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(7, 7)
(8, 7)cell=(8, 6) neighbor=(8, 7)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(8, 7)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(8, 7)
(9, 6)cell=(8, 6) neighbor=(9, 6)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(9, 6)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(9, 6)
(9, 5)cell=(8, 6) neighbor=(9, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(9, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(9, 5)
(7, 6)cell=(8, 6) neighbor=(7, 6)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(7, 6)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(7, 6)
(7, 5)cell=(8, 6) neighbor=(7, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(7, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(7, 5)
(9, 7)cell=(8, 6) neighbor=(9, 7)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(9, 7)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(9, 7)
(8, 5)cell=(8, 6) neighbor=(8, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(8, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(8, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 6) neighbor=(8, 5)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(2, 2)
return { cell=(2, 2)
for dx in [-1, 0, 1]cell=(2, 2)
return { cell=(2, 2)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(2, 2)
return { cell=(2, 2)
for dx in [-1, 0, 1]cell=(2, 2)
for dy in [-1, 0, 1]cell=(2, 2) dx=-1
return { cell=(2, 2) dx=-1
for dy in [-1, 0, 1]cell=(2, 2) dx=-1
if (dx, dy) != (0, 0)cell=(2, 2) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(2, 2) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(2, 2) dx=-1 dy=-1
return { cell=(2, 2) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(2, 2) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(2, 2) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(2, 2) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(2, 2) dx=-1 dy=0
return { cell=(2, 2) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(2, 2) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(2, 2) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(2, 2) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(2, 2) dx=-1 dy=1
return { cell=(2, 2) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(2, 2) dx=-1 dy=1
return { cell=(2, 2) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(2, 2) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(2, 2) dx=0 dy=1
return { cell=(2, 2) dx=0 dy=1
for dy in [-1, 0, 1]cell=(2, 2) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(2, 2) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(2, 2) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(2, 2) dx=0 dy=-1
return { cell=(2, 2) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(2, 2) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(2, 2) dx=0 dy=0
return { cell=(2, 2) dx=0 dy=0
for dy in [-1, 0, 1]cell=(2, 2) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(2, 2) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(2, 2) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(2, 2) dx=0 dy=1
return { cell=(2, 2) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(2, 2) dx=0 dy=1
return { cell=(2, 2) dx=0 dy=1
for dx in [-1, 0, 1]cell=(2, 2) dx=0 dy=1
for dy in [-1, 0, 1]cell=(2, 2) dx=1 dy=1
return { cell=(2, 2) dx=1 dy=1
for dy in [-1, 0, 1]cell=(2, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(2, 2) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(2, 2) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(2, 2) dx=1 dy=-1
return { cell=(2, 2) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(2, 2) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(2, 2) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(2, 2) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(2, 2) dx=1 dy=0
return { cell=(2, 2) dx=1 dy=0
for dy in [-1, 0, 1]cell=(2, 2) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(2, 2) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(2, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(2, 2) dx=1 dy=1
return { cell=(2, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(2, 2) dx=1 dy=1
return { cell=(2, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(2, 2) dx=1 dy=1
{(1, 2), (2, 1), (3, 1), (1, 1), (2, 3), (3, 3), (3, 2), (1, 3)} cell=(2, 2) dx=1 dy=1
{(1, 2), (2, 1), (3, 1), (1, 1), (2, 3), (3, 3), (3, 2), (1, 3)} cell=(2, 2)
(1, 2)cell=(2, 2) neighbor=(1, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(1, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(1, 2)
(2, 1)cell=(2, 2) neighbor=(2, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(2, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(2, 1)
(3, 1)cell=(2, 2) neighbor=(3, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(3, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(3, 1)
(1, 1)cell=(2, 2) neighbor=(1, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(1, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(1, 1)
(2, 3)cell=(2, 2) neighbor=(2, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(2, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(2, 3)
(3, 3)cell=(2, 2) neighbor=(3, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(3, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(3, 3)
(3, 2)cell=(2, 2) neighbor=(3, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(3, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(3, 2)
(1, 3)cell=(2, 2) neighbor=(1, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(1, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(1, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 2) neighbor=(1, 3)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(1, 6)
return { cell=(1, 6)
for dx in [-1, 0, 1]cell=(1, 6)
return { cell=(1, 6)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(1, 6)
return { cell=(1, 6)
for dx in [-1, 0, 1]cell=(1, 6)
for dy in [-1, 0, 1]cell=(1, 6) dx=-1
return { cell=(1, 6) dx=-1
for dy in [-1, 0, 1]cell=(1, 6) dx=-1
if (dx, dy) != (0, 0)cell=(1, 6) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(1, 6) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(1, 6) dx=-1 dy=-1
return { cell=(1, 6) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(1, 6) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(1, 6) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(1, 6) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(1, 6) dx=-1 dy=0
return { cell=(1, 6) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(1, 6) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(1, 6) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(1, 6) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(1, 6) dx=-1 dy=1
return { cell=(1, 6) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(1, 6) dx=-1 dy=1
return { cell=(1, 6) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(1, 6) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(1, 6) dx=0 dy=1
return { cell=(1, 6) dx=0 dy=1
for dy in [-1, 0, 1]cell=(1, 6) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(1, 6) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(1, 6) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(1, 6) dx=0 dy=-1
return { cell=(1, 6) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(1, 6) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(1, 6) dx=0 dy=0
return { cell=(1, 6) dx=0 dy=0
for dy in [-1, 0, 1]cell=(1, 6) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(1, 6) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(1, 6) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(1, 6) dx=0 dy=1
return { cell=(1, 6) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(1, 6) dx=0 dy=1
return { cell=(1, 6) dx=0 dy=1
for dx in [-1, 0, 1]cell=(1, 6) dx=0 dy=1
for dy in [-1, 0, 1]cell=(1, 6) dx=1 dy=1
return { cell=(1, 6) dx=1 dy=1
for dy in [-1, 0, 1]cell=(1, 6) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(1, 6) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(1, 6) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(1, 6) dx=1 dy=-1
return { cell=(1, 6) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(1, 6) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(1, 6) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(1, 6) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(1, 6) dx=1 dy=0
return { cell=(1, 6) dx=1 dy=0
for dy in [-1, 0, 1]cell=(1, 6) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(1, 6) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(1, 6) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(1, 6) dx=1 dy=1
return { cell=(1, 6) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(1, 6) dx=1 dy=1
return { cell=(1, 6) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(1, 6) dx=1 dy=1
{(0, 7), (2, 7), (1, 5), (0, 6), (1, 7), (2, 6), (0, 5), (2, 5)} cell=(1, 6) dx=1 dy=1
{(0, 7), (2, 7), (1, 5), (0, 6), (1, 7), (2, 6), (0, 5), (2, 5)} cell=(1, 6)
(0, 7)cell=(1, 6) neighbor=(0, 7)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(0, 7)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(0, 7)
(2, 7)cell=(1, 6) neighbor=(2, 7)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(2, 7)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(2, 7)
(1, 5)cell=(1, 6) neighbor=(1, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(1, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(1, 5)
(0, 6)cell=(1, 6) neighbor=(0, 6)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(0, 6)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(0, 6)
(1, 7)cell=(1, 6) neighbor=(1, 7)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(1, 7)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(1, 7)
(2, 6)cell=(1, 6) neighbor=(2, 6)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(2, 6)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(2, 6)
(0, 5)cell=(1, 6) neighbor=(0, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(0, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(0, 5)
(2, 5)cell=(1, 6) neighbor=(2, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(2, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(2, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(1, 6) neighbor=(2, 5)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(4, 2)
return { cell=(4, 2)
for dx in [-1, 0, 1]cell=(4, 2)
return { cell=(4, 2)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(4, 2)
return { cell=(4, 2)
for dx in [-1, 0, 1]cell=(4, 2)
for dy in [-1, 0, 1]cell=(4, 2) dx=-1
return { cell=(4, 2) dx=-1
for dy in [-1, 0, 1]cell=(4, 2) dx=-1
if (dx, dy) != (0, 0)cell=(4, 2) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(4, 2) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(4, 2) dx=-1 dy=-1
return { cell=(4, 2) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(4, 2) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(4, 2) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(4, 2) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(4, 2) dx=-1 dy=0
return { cell=(4, 2) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(4, 2) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(4, 2) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(4, 2) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(4, 2) dx=-1 dy=1
return { cell=(4, 2) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(4, 2) dx=-1 dy=1
return { cell=(4, 2) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(4, 2) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(4, 2) dx=0 dy=1
return { cell=(4, 2) dx=0 dy=1
for dy in [-1, 0, 1]cell=(4, 2) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(4, 2) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(4, 2) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(4, 2) dx=0 dy=-1
return { cell=(4, 2) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(4, 2) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(4, 2) dx=0 dy=0
return { cell=(4, 2) dx=0 dy=0
for dy in [-1, 0, 1]cell=(4, 2) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(4, 2) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(4, 2) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(4, 2) dx=0 dy=1
return { cell=(4, 2) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(4, 2) dx=0 dy=1
return { cell=(4, 2) dx=0 dy=1
for dx in [-1, 0, 1]cell=(4, 2) dx=0 dy=1
for dy in [-1, 0, 1]cell=(4, 2) dx=1 dy=1
return { cell=(4, 2) dx=1 dy=1
for dy in [-1, 0, 1]cell=(4, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(4, 2) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(4, 2) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(4, 2) dx=1 dy=-1
return { cell=(4, 2) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(4, 2) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(4, 2) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(4, 2) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(4, 2) dx=1 dy=0
return { cell=(4, 2) dx=1 dy=0
for dy in [-1, 0, 1]cell=(4, 2) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(4, 2) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(4, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(4, 2) dx=1 dy=1
return { cell=(4, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(4, 2) dx=1 dy=1
return { cell=(4, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(4, 2) dx=1 dy=1
{(4, 3), (3, 1), (5, 1), (3, 3), (5, 3), (3, 2), (4, 1), (5, 2)} cell=(4, 2) dx=1 dy=1
{(4, 3), (3, 1), (5, 1), (3, 3), (5, 3), (3, 2), (4, 1), (5, 2)} cell=(4, 2)
(4, 3)cell=(4, 2) neighbor=(4, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(4, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(4, 3)
(3, 1)cell=(4, 2) neighbor=(3, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(3, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(3, 1)
(5, 1)cell=(4, 2) neighbor=(5, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(5, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(5, 1)
(3, 3)cell=(4, 2) neighbor=(3, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(3, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(3, 3)
(5, 3)cell=(4, 2) neighbor=(5, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(5, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(5, 3)
(3, 2)cell=(4, 2) neighbor=(3, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(3, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(3, 2)
(4, 1)cell=(4, 2) neighbor=(4, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(4, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(4, 1)
(5, 2)cell=(4, 2) neighbor=(5, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(5, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(5, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(4, 2) neighbor=(5, 2)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(8, 2)
return { cell=(8, 2)
for dx in [-1, 0, 1]cell=(8, 2)
return { cell=(8, 2)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(8, 2)
return { cell=(8, 2)
for dx in [-1, 0, 1]cell=(8, 2)
for dy in [-1, 0, 1]cell=(8, 2) dx=-1
return { cell=(8, 2) dx=-1
for dy in [-1, 0, 1]cell=(8, 2) dx=-1
if (dx, dy) != (0, 0)cell=(8, 2) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(8, 2) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 2) dx=-1 dy=-1
return { cell=(8, 2) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(8, 2) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 2) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(8, 2) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(8, 2) dx=-1 dy=0
return { cell=(8, 2) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(8, 2) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(8, 2) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(8, 2) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(8, 2) dx=-1 dy=1
return { cell=(8, 2) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(8, 2) dx=-1 dy=1
return { cell=(8, 2) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(8, 2) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(8, 2) dx=0 dy=1
return { cell=(8, 2) dx=0 dy=1
for dy in [-1, 0, 1]cell=(8, 2) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(8, 2) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(8, 2) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(8, 2) dx=0 dy=-1
return { cell=(8, 2) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(8, 2) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(8, 2) dx=0 dy=0
return { cell=(8, 2) dx=0 dy=0
for dy in [-1, 0, 1]cell=(8, 2) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(8, 2) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(8, 2) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(8, 2) dx=0 dy=1
return { cell=(8, 2) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(8, 2) dx=0 dy=1
return { cell=(8, 2) dx=0 dy=1
for dx in [-1, 0, 1]cell=(8, 2) dx=0 dy=1
for dy in [-1, 0, 1]cell=(8, 2) dx=1 dy=1
return { cell=(8, 2) dx=1 dy=1
for dy in [-1, 0, 1]cell=(8, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 2) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(8, 2) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 2) dx=1 dy=-1
return { cell=(8, 2) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(8, 2) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 2) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(8, 2) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(8, 2) dx=1 dy=0
return { cell=(8, 2) dx=1 dy=0
for dy in [-1, 0, 1]cell=(8, 2) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(8, 2) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(8, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 2) dx=1 dy=1
return { cell=(8, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 2) dx=1 dy=1
return { cell=(8, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 2) dx=1 dy=1
{(7, 1), (9, 3), (8, 1), (9, 2), (7, 3), (8, 3), (7, 2), (9, 1)} cell=(8, 2) dx=1 dy=1
{(7, 1), (9, 3), (8, 1), (9, 2), (7, 3), (8, 3), (7, 2), (9, 1)} cell=(8, 2)
(7, 1)cell=(8, 2) neighbor=(7, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(7, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(7, 1)
(9, 3)cell=(8, 2) neighbor=(9, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(9, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(9, 3)
(8, 1)cell=(8, 2) neighbor=(8, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(8, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(8, 1)
(9, 2)cell=(8, 2) neighbor=(9, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(9, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(9, 2)
(7, 3)cell=(8, 2) neighbor=(7, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(7, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(7, 3)
(8, 3)cell=(8, 2) neighbor=(8, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(8, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(8, 3)
(7, 2)cell=(8, 2) neighbor=(7, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(7, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(7, 2)
(9, 1)cell=(8, 2) neighbor=(9, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(9, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(9, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 2) neighbor=(9, 1)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(8, 8)
return { cell=(8, 8)
for dx in [-1, 0, 1]cell=(8, 8)
return { cell=(8, 8)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(8, 8)
return { cell=(8, 8)
for dx in [-1, 0, 1]cell=(8, 8)
for dy in [-1, 0, 1]cell=(8, 8) dx=-1
return { cell=(8, 8) dx=-1
for dy in [-1, 0, 1]cell=(8, 8) dx=-1
if (dx, dy) != (0, 0)cell=(8, 8) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(8, 8) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 8) dx=-1 dy=-1
return { cell=(8, 8) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(8, 8) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 8) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(8, 8) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(8, 8) dx=-1 dy=0
return { cell=(8, 8) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(8, 8) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(8, 8) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(8, 8) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(8, 8) dx=-1 dy=1
return { cell=(8, 8) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(8, 8) dx=-1 dy=1
return { cell=(8, 8) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(8, 8) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(8, 8) dx=0 dy=1
return { cell=(8, 8) dx=0 dy=1
for dy in [-1, 0, 1]cell=(8, 8) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(8, 8) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(8, 8) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(8, 8) dx=0 dy=-1
return { cell=(8, 8) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(8, 8) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(8, 8) dx=0 dy=0
return { cell=(8, 8) dx=0 dy=0
for dy in [-1, 0, 1]cell=(8, 8) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(8, 8) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(8, 8) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(8, 8) dx=0 dy=1
return { cell=(8, 8) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(8, 8) dx=0 dy=1
return { cell=(8, 8) dx=0 dy=1
for dx in [-1, 0, 1]cell=(8, 8) dx=0 dy=1
for dy in [-1, 0, 1]cell=(8, 8) dx=1 dy=1
return { cell=(8, 8) dx=1 dy=1
for dy in [-1, 0, 1]cell=(8, 8) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 8) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(8, 8) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 8) dx=1 dy=-1
return { cell=(8, 8) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(8, 8) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(8, 8) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(8, 8) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(8, 8) dx=1 dy=0
return { cell=(8, 8) dx=1 dy=0
for dy in [-1, 0, 1]cell=(8, 8) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(8, 8) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(8, 8) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 8) dx=1 dy=1
return { cell=(8, 8) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 8) dx=1 dy=1
return { cell=(8, 8) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(8, 8) dx=1 dy=1
{(7, 7), (9, 9), (8, 7), (7, 9), (8, 9), (9, 8), (9, 7), (7, 8)} cell=(8, 8) dx=1 dy=1
{(7, 7), (9, 9), (8, 7), (7, 9), (8, 9), (9, 8), (9, 7), (7, 8)} cell=(8, 8)
(7, 7)cell=(8, 8) neighbor=(7, 7)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(7, 7)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(7, 7)
(9, 9)cell=(8, 8) neighbor=(9, 9)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(9, 9)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(9, 9)
(8, 7)cell=(8, 8) neighbor=(8, 7)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(8, 7)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(8, 7)
(7, 9)cell=(8, 8) neighbor=(7, 9)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(7, 9)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(7, 9)
(8, 9)cell=(8, 8) neighbor=(8, 9)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(8, 9)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(8, 9)
(9, 8)cell=(8, 8) neighbor=(9, 8)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(9, 8)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(9, 8)
(9, 7)cell=(8, 8) neighbor=(9, 7)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(9, 7)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(9, 7)
(7, 8)cell=(8, 8) neighbor=(7, 8)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(7, 8)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(7, 8)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(8, 8) neighbor=(7, 8)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(6, 1)
return { cell=(6, 1)
for dx in [-1, 0, 1]cell=(6, 1)
return { cell=(6, 1)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(6, 1)
return { cell=(6, 1)
for dx in [-1, 0, 1]cell=(6, 1)
for dy in [-1, 0, 1]cell=(6, 1) dx=-1
return { cell=(6, 1) dx=-1
for dy in [-1, 0, 1]cell=(6, 1) dx=-1
if (dx, dy) != (0, 0)cell=(6, 1) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(6, 1) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(6, 1) dx=-1 dy=-1
return { cell=(6, 1) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(6, 1) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(6, 1) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(6, 1) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(6, 1) dx=-1 dy=0
return { cell=(6, 1) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(6, 1) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(6, 1) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(6, 1) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(6, 1) dx=-1 dy=1
return { cell=(6, 1) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(6, 1) dx=-1 dy=1
return { cell=(6, 1) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(6, 1) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(6, 1) dx=0 dy=1
return { cell=(6, 1) dx=0 dy=1
for dy in [-1, 0, 1]cell=(6, 1) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(6, 1) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(6, 1) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(6, 1) dx=0 dy=-1
return { cell=(6, 1) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(6, 1) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(6, 1) dx=0 dy=0
return { cell=(6, 1) dx=0 dy=0
for dy in [-1, 0, 1]cell=(6, 1) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(6, 1) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(6, 1) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(6, 1) dx=0 dy=1
return { cell=(6, 1) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(6, 1) dx=0 dy=1
return { cell=(6, 1) dx=0 dy=1
for dx in [-1, 0, 1]cell=(6, 1) dx=0 dy=1
for dy in [-1, 0, 1]cell=(6, 1) dx=1 dy=1
return { cell=(6, 1) dx=1 dy=1
for dy in [-1, 0, 1]cell=(6, 1) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(6, 1) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(6, 1) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(6, 1) dx=1 dy=-1
return { cell=(6, 1) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(6, 1) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(6, 1) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(6, 1) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(6, 1) dx=1 dy=0
return { cell=(6, 1) dx=1 dy=0
for dy in [-1, 0, 1]cell=(6, 1) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(6, 1) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(6, 1) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(6, 1) dx=1 dy=1
return { cell=(6, 1) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(6, 1) dx=1 dy=1
return { cell=(6, 1) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(6, 1) dx=1 dy=1
{(6, 2), (7, 1), (7, 0), (5, 1), (5, 0), (7, 2), (6, 0), (5, 2)} cell=(6, 1) dx=1 dy=1
{(6, 2), (7, 1), (7, 0), (5, 1), (5, 0), (7, 2), (6, 0), (5, 2)} cell=(6, 1)
(6, 2)cell=(6, 1) neighbor=(6, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(6, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(6, 2)
(7, 1)cell=(6, 1) neighbor=(7, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(7, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(7, 1)
(7, 0)cell=(6, 1) neighbor=(7, 0)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(7, 0)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(7, 0)
(5, 1)cell=(6, 1) neighbor=(5, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(5, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(5, 1)
(5, 0)cell=(6, 1) neighbor=(5, 0)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(5, 0)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(5, 0)
(7, 2)cell=(6, 1) neighbor=(7, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(7, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(7, 2)
(6, 0)cell=(6, 1) neighbor=(6, 0)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(6, 0)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(6, 0)
(5, 2)cell=(6, 1) neighbor=(5, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(5, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(5, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 1) neighbor=(5, 2)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(7, 9)
return { cell=(7, 9)
for dx in [-1, 0, 1]cell=(7, 9)
return { cell=(7, 9)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(7, 9)
return { cell=(7, 9)
for dx in [-1, 0, 1]cell=(7, 9)
for dy in [-1, 0, 1]cell=(7, 9) dx=-1
return { cell=(7, 9) dx=-1
for dy in [-1, 0, 1]cell=(7, 9) dx=-1
if (dx, dy) != (0, 0)cell=(7, 9) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(7, 9) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(7, 9) dx=-1 dy=-1
return { cell=(7, 9) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(7, 9) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(7, 9) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(7, 9) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(7, 9) dx=-1 dy=0
return { cell=(7, 9) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(7, 9) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(7, 9) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(7, 9) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(7, 9) dx=-1 dy=1
return { cell=(7, 9) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(7, 9) dx=-1 dy=1
return { cell=(7, 9) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(7, 9) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(7, 9) dx=0 dy=1
return { cell=(7, 9) dx=0 dy=1
for dy in [-1, 0, 1]cell=(7, 9) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(7, 9) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(7, 9) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(7, 9) dx=0 dy=-1
return { cell=(7, 9) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(7, 9) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(7, 9) dx=0 dy=0
return { cell=(7, 9) dx=0 dy=0
for dy in [-1, 0, 1]cell=(7, 9) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(7, 9) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(7, 9) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(7, 9) dx=0 dy=1
return { cell=(7, 9) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(7, 9) dx=0 dy=1
return { cell=(7, 9) dx=0 dy=1
for dx in [-1, 0, 1]cell=(7, 9) dx=0 dy=1
for dy in [-1, 0, 1]cell=(7, 9) dx=1 dy=1
return { cell=(7, 9) dx=1 dy=1
for dy in [-1, 0, 1]cell=(7, 9) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(7, 9) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(7, 9) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(7, 9) dx=1 dy=-1
return { cell=(7, 9) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(7, 9) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(7, 9) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(7, 9) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(7, 9) dx=1 dy=0
return { cell=(7, 9) dx=1 dy=0
for dy in [-1, 0, 1]cell=(7, 9) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(7, 9) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(7, 9) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(7, 9) dx=1 dy=1
return { cell=(7, 9) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(7, 9) dx=1 dy=1
return { cell=(7, 9) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(7, 9) dx=1 dy=1
{(8, 8), (7, 10), (6, 8), (8, 10), (8, 9), (6, 10), (6, 9), (7, 8)} cell=(7, 9) dx=1 dy=1
{(8, 8), (7, 10), (6, 8), (8, 10), (8, 9), (6, 10), (6, 9), (7, 8)} cell=(7, 9)
(8, 8)cell=(7, 9) neighbor=(8, 8)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(8, 8)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(8, 8)
(7, 10)cell=(7, 9) neighbor=(7, 10)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(7, 10)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(7, 10)
(6, 8)cell=(7, 9) neighbor=(6, 8)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(6, 8)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(6, 8)
(8, 10)cell=(7, 9) neighbor=(8, 10)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(8, 10)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(8, 10)
(8, 9)cell=(7, 9) neighbor=(8, 9)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(8, 9)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(8, 9)
(6, 10)cell=(7, 9) neighbor=(6, 10)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(6, 10)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(6, 10)
(6, 9)cell=(7, 9) neighbor=(6, 9)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(6, 9)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(6, 9)
(7, 8)cell=(7, 9) neighbor=(7, 8)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(7, 8)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(7, 8)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 9) neighbor=(7, 8)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(3, 2)
return { cell=(3, 2)
for dx in [-1, 0, 1]cell=(3, 2)
return { cell=(3, 2)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(3, 2)
return { cell=(3, 2)
for dx in [-1, 0, 1]cell=(3, 2)
for dy in [-1, 0, 1]cell=(3, 2) dx=-1
return { cell=(3, 2) dx=-1
for dy in [-1, 0, 1]cell=(3, 2) dx=-1
if (dx, dy) != (0, 0)cell=(3, 2) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(3, 2) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(3, 2) dx=-1 dy=-1
return { cell=(3, 2) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(3, 2) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(3, 2) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(3, 2) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(3, 2) dx=-1 dy=0
return { cell=(3, 2) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(3, 2) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(3, 2) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(3, 2) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(3, 2) dx=-1 dy=1
return { cell=(3, 2) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(3, 2) dx=-1 dy=1
return { cell=(3, 2) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(3, 2) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(3, 2) dx=0 dy=1
return { cell=(3, 2) dx=0 dy=1
for dy in [-1, 0, 1]cell=(3, 2) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(3, 2) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(3, 2) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(3, 2) dx=0 dy=-1
return { cell=(3, 2) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(3, 2) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(3, 2) dx=0 dy=0
return { cell=(3, 2) dx=0 dy=0
for dy in [-1, 0, 1]cell=(3, 2) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(3, 2) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(3, 2) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(3, 2) dx=0 dy=1
return { cell=(3, 2) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(3, 2) dx=0 dy=1
return { cell=(3, 2) dx=0 dy=1
for dx in [-1, 0, 1]cell=(3, 2) dx=0 dy=1
for dy in [-1, 0, 1]cell=(3, 2) dx=1 dy=1
return { cell=(3, 2) dx=1 dy=1
for dy in [-1, 0, 1]cell=(3, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(3, 2) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(3, 2) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(3, 2) dx=1 dy=-1
return { cell=(3, 2) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(3, 2) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(3, 2) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(3, 2) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(3, 2) dx=1 dy=0
return { cell=(3, 2) dx=1 dy=0
for dy in [-1, 0, 1]cell=(3, 2) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(3, 2) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(3, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(3, 2) dx=1 dy=1
return { cell=(3, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(3, 2) dx=1 dy=1
return { cell=(3, 2) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(3, 2) dx=1 dy=1
{(2, 1), (4, 3), (3, 1), (4, 2), (2, 3), (3, 3), (2, 2), (4, 1)} cell=(3, 2) dx=1 dy=1
{(2, 1), (4, 3), (3, 1), (4, 2), (2, 3), (3, 3), (2, 2), (4, 1)} cell=(3, 2)
(2, 1)cell=(3, 2) neighbor=(2, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(2, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(2, 1)
(4, 3)cell=(3, 2) neighbor=(4, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(4, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(4, 3)
(3, 1)cell=(3, 2) neighbor=(3, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(3, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(3, 1)
(4, 2)cell=(3, 2) neighbor=(4, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(4, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(4, 2)
(2, 3)cell=(3, 2) neighbor=(2, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(2, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(2, 3)
(3, 3)cell=(3, 2) neighbor=(3, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(3, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(3, 3)
(2, 2)cell=(3, 2) neighbor=(2, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(2, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(2, 2)
(4, 1)cell=(3, 2) neighbor=(4, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(4, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(4, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 2) neighbor=(4, 1)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(3, 5)
return { cell=(3, 5)
for dx in [-1, 0, 1]cell=(3, 5)
return { cell=(3, 5)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(3, 5)
return { cell=(3, 5)
for dx in [-1, 0, 1]cell=(3, 5)
for dy in [-1, 0, 1]cell=(3, 5) dx=-1
return { cell=(3, 5) dx=-1
for dy in [-1, 0, 1]cell=(3, 5) dx=-1
if (dx, dy) != (0, 0)cell=(3, 5) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(3, 5) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(3, 5) dx=-1 dy=-1
return { cell=(3, 5) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(3, 5) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(3, 5) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(3, 5) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(3, 5) dx=-1 dy=0
return { cell=(3, 5) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(3, 5) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(3, 5) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(3, 5) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(3, 5) dx=-1 dy=1
return { cell=(3, 5) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(3, 5) dx=-1 dy=1
return { cell=(3, 5) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(3, 5) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(3, 5) dx=0 dy=1
return { cell=(3, 5) dx=0 dy=1
for dy in [-1, 0, 1]cell=(3, 5) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(3, 5) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(3, 5) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(3, 5) dx=0 dy=-1
return { cell=(3, 5) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(3, 5) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(3, 5) dx=0 dy=0
return { cell=(3, 5) dx=0 dy=0
for dy in [-1, 0, 1]cell=(3, 5) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(3, 5) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(3, 5) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(3, 5) dx=0 dy=1
return { cell=(3, 5) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(3, 5) dx=0 dy=1
return { cell=(3, 5) dx=0 dy=1
for dx in [-1, 0, 1]cell=(3, 5) dx=0 dy=1
for dy in [-1, 0, 1]cell=(3, 5) dx=1 dy=1
return { cell=(3, 5) dx=1 dy=1
for dy in [-1, 0, 1]cell=(3, 5) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(3, 5) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(3, 5) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(3, 5) dx=1 dy=-1
return { cell=(3, 5) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(3, 5) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(3, 5) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(3, 5) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(3, 5) dx=1 dy=0
return { cell=(3, 5) dx=1 dy=0
for dy in [-1, 0, 1]cell=(3, 5) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(3, 5) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(3, 5) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(3, 5) dx=1 dy=1
return { cell=(3, 5) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(3, 5) dx=1 dy=1
return { cell=(3, 5) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(3, 5) dx=1 dy=1
{(4, 4), (2, 4), (3, 4), (4, 6), (4, 5), (2, 6), (3, 6), (2, 5)} cell=(3, 5) dx=1 dy=1
{(4, 4), (2, 4), (3, 4), (4, 6), (4, 5), (2, 6), (3, 6), (2, 5)} cell=(3, 5)
(4, 4)cell=(3, 5) neighbor=(4, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(4, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(4, 4)
(2, 4)cell=(3, 5) neighbor=(2, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(2, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(2, 4)
(3, 4)cell=(3, 5) neighbor=(3, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(3, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(3, 4)
(4, 6)cell=(3, 5) neighbor=(4, 6)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(4, 6)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(4, 6)
(4, 5)cell=(3, 5) neighbor=(4, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(4, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(4, 5)
(2, 6)cell=(3, 5) neighbor=(2, 6)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(2, 6)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(2, 6)
(3, 6)cell=(3, 5) neighbor=(3, 6)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(3, 6)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(3, 6)
(2, 5)cell=(3, 5) neighbor=(2, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(2, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(2, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(3, 5) neighbor=(2, 5)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(9, 3)
return { cell=(9, 3)
for dx in [-1, 0, 1]cell=(9, 3)
return { cell=(9, 3)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(9, 3)
return { cell=(9, 3)
for dx in [-1, 0, 1]cell=(9, 3)
for dy in [-1, 0, 1]cell=(9, 3) dx=-1
return { cell=(9, 3) dx=-1
for dy in [-1, 0, 1]cell=(9, 3) dx=-1
if (dx, dy) != (0, 0)cell=(9, 3) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(9, 3) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(9, 3) dx=-1 dy=-1
return { cell=(9, 3) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(9, 3) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(9, 3) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(9, 3) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(9, 3) dx=-1 dy=0
return { cell=(9, 3) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(9, 3) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(9, 3) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(9, 3) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(9, 3) dx=-1 dy=1
return { cell=(9, 3) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(9, 3) dx=-1 dy=1
return { cell=(9, 3) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(9, 3) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(9, 3) dx=0 dy=1
return { cell=(9, 3) dx=0 dy=1
for dy in [-1, 0, 1]cell=(9, 3) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(9, 3) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(9, 3) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(9, 3) dx=0 dy=-1
return { cell=(9, 3) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(9, 3) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(9, 3) dx=0 dy=0
return { cell=(9, 3) dx=0 dy=0
for dy in [-1, 0, 1]cell=(9, 3) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(9, 3) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(9, 3) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(9, 3) dx=0 dy=1
return { cell=(9, 3) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(9, 3) dx=0 dy=1
return { cell=(9, 3) dx=0 dy=1
for dx in [-1, 0, 1]cell=(9, 3) dx=0 dy=1
for dy in [-1, 0, 1]cell=(9, 3) dx=1 dy=1
return { cell=(9, 3) dx=1 dy=1
for dy in [-1, 0, 1]cell=(9, 3) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(9, 3) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(9, 3) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(9, 3) dx=1 dy=-1
return { cell=(9, 3) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(9, 3) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(9, 3) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(9, 3) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(9, 3) dx=1 dy=0
return { cell=(9, 3) dx=1 dy=0
for dy in [-1, 0, 1]cell=(9, 3) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(9, 3) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(9, 3) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(9, 3) dx=1 dy=1
return { cell=(9, 3) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(9, 3) dx=1 dy=1
return { cell=(9, 3) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(9, 3) dx=1 dy=1
{(8, 4), (10, 4), (9, 2), (8, 3), (10, 3), (8, 2), (10, 2), (9, 4)} cell=(9, 3) dx=1 dy=1
{(8, 4), (10, 4), (9, 2), (8, 3), (10, 3), (8, 2), (10, 2), (9, 4)} cell=(9, 3)
(8, 4)cell=(9, 3) neighbor=(8, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(8, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(8, 4)
(10, 4)cell=(9, 3) neighbor=(10, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(10, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(10, 4)
(9, 2)cell=(9, 3) neighbor=(9, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(9, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(9, 2)
(8, 3)cell=(9, 3) neighbor=(8, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(8, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(8, 3)
(10, 3)cell=(9, 3) neighbor=(10, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(10, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(10, 3)
(8, 2)cell=(9, 3) neighbor=(8, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(8, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(8, 2)
(10, 2)cell=(9, 3) neighbor=(10, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(10, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(10, 2)
(9, 4)cell=(9, 3) neighbor=(9, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(9, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(9, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(9, 3) neighbor=(9, 4)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(0, 3)
return { cell=(0, 3)
for dx in [-1, 0, 1]cell=(0, 3)
return { cell=(0, 3)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(0, 3)
return { cell=(0, 3)
for dx in [-1, 0, 1]cell=(0, 3)
for dy in [-1, 0, 1]cell=(0, 3) dx=-1
return { cell=(0, 3) dx=-1
for dy in [-1, 0, 1]cell=(0, 3) dx=-1
if (dx, dy) != (0, 0)cell=(0, 3) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(0, 3) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(0, 3) dx=-1 dy=-1
return { cell=(0, 3) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(0, 3) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(0, 3) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(0, 3) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(0, 3) dx=-1 dy=0
return { cell=(0, 3) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(0, 3) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(0, 3) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(0, 3) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(0, 3) dx=-1 dy=1
return { cell=(0, 3) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(0, 3) dx=-1 dy=1
return { cell=(0, 3) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(0, 3) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(0, 3) dx=0 dy=1
return { cell=(0, 3) dx=0 dy=1
for dy in [-1, 0, 1]cell=(0, 3) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(0, 3) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(0, 3) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(0, 3) dx=0 dy=-1
return { cell=(0, 3) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(0, 3) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(0, 3) dx=0 dy=0
return { cell=(0, 3) dx=0 dy=0
for dy in [-1, 0, 1]cell=(0, 3) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(0, 3) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(0, 3) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(0, 3) dx=0 dy=1
return { cell=(0, 3) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(0, 3) dx=0 dy=1
return { cell=(0, 3) dx=0 dy=1
for dx in [-1, 0, 1]cell=(0, 3) dx=0 dy=1
for dy in [-1, 0, 1]cell=(0, 3) dx=1 dy=1
return { cell=(0, 3) dx=1 dy=1
for dy in [-1, 0, 1]cell=(0, 3) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(0, 3) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(0, 3) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(0, 3) dx=1 dy=-1
return { cell=(0, 3) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(0, 3) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(0, 3) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(0, 3) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(0, 3) dx=1 dy=0
return { cell=(0, 3) dx=1 dy=0
for dy in [-1, 0, 1]cell=(0, 3) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(0, 3) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(0, 3) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(0, 3) dx=1 dy=1
return { cell=(0, 3) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(0, 3) dx=1 dy=1
return { cell=(0, 3) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(0, 3) dx=1 dy=1
{(1, 2), (0, 4), (-1, 4), (1, 4), (0, 2), (-1, 3), (-1, 2), (1, 3)} cell=(0, 3) dx=1 dy=1
{(1, 2), (0, 4), (-1, 4), (1, 4), (0, 2), (-1, 3), (-1, 2), (1, 3)} cell=(0, 3)
(1, 2)cell=(0, 3) neighbor=(1, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(1, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(1, 2)
(0, 4)cell=(0, 3) neighbor=(0, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(0, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(0, 4)
(-1, 4)cell=(0, 3) neighbor=(-1, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(-1, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(-1, 4)
(1, 4)cell=(0, 3) neighbor=(1, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(1, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(1, 4)
(0, 2)cell=(0, 3) neighbor=(0, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(0, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(0, 2)
(-1, 3)cell=(0, 3) neighbor=(-1, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(-1, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(-1, 3)
(-1, 2)cell=(0, 3) neighbor=(-1, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(-1, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(-1, 2)
(1, 3)cell=(0, 3) neighbor=(1, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(1, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(1, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(0, 3) neighbor=(1, 3)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(2, 3)
return { cell=(2, 3)
for dx in [-1, 0, 1]cell=(2, 3)
return { cell=(2, 3)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(2, 3)
return { cell=(2, 3)
for dx in [-1, 0, 1]cell=(2, 3)
for dy in [-1, 0, 1]cell=(2, 3) dx=-1
return { cell=(2, 3) dx=-1
for dy in [-1, 0, 1]cell=(2, 3) dx=-1
if (dx, dy) != (0, 0)cell=(2, 3) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(2, 3) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(2, 3) dx=-1 dy=-1
return { cell=(2, 3) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(2, 3) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(2, 3) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(2, 3) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(2, 3) dx=-1 dy=0
return { cell=(2, 3) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(2, 3) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(2, 3) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(2, 3) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(2, 3) dx=-1 dy=1
return { cell=(2, 3) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(2, 3) dx=-1 dy=1
return { cell=(2, 3) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(2, 3) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(2, 3) dx=0 dy=1
return { cell=(2, 3) dx=0 dy=1
for dy in [-1, 0, 1]cell=(2, 3) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(2, 3) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(2, 3) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(2, 3) dx=0 dy=-1
return { cell=(2, 3) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(2, 3) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(2, 3) dx=0 dy=0
return { cell=(2, 3) dx=0 dy=0
for dy in [-1, 0, 1]cell=(2, 3) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(2, 3) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(2, 3) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(2, 3) dx=0 dy=1
return { cell=(2, 3) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(2, 3) dx=0 dy=1
return { cell=(2, 3) dx=0 dy=1
for dx in [-1, 0, 1]cell=(2, 3) dx=0 dy=1
for dy in [-1, 0, 1]cell=(2, 3) dx=1 dy=1
return { cell=(2, 3) dx=1 dy=1
for dy in [-1, 0, 1]cell=(2, 3) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(2, 3) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(2, 3) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(2, 3) dx=1 dy=-1
return { cell=(2, 3) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(2, 3) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(2, 3) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(2, 3) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(2, 3) dx=1 dy=0
return { cell=(2, 3) dx=1 dy=0
for dy in [-1, 0, 1]cell=(2, 3) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(2, 3) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(2, 3) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(2, 3) dx=1 dy=1
return { cell=(2, 3) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(2, 3) dx=1 dy=1
return { cell=(2, 3) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(2, 3) dx=1 dy=1
{(2, 4), (1, 2), (3, 4), (1, 4), (3, 3), (2, 2), (3, 2), (1, 3)} cell=(2, 3) dx=1 dy=1
{(2, 4), (1, 2), (3, 4), (1, 4), (3, 3), (2, 2), (3, 2), (1, 3)} cell=(2, 3)
(2, 4)cell=(2, 3) neighbor=(2, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(2, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(2, 4)
(1, 2)cell=(2, 3) neighbor=(1, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(1, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(1, 2)
(3, 4)cell=(2, 3) neighbor=(3, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(3, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(3, 4)
(1, 4)cell=(2, 3) neighbor=(1, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(1, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(1, 4)
(3, 3)cell=(2, 3) neighbor=(3, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(3, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(3, 3)
(2, 2)cell=(2, 3) neighbor=(2, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(2, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(2, 2)
(3, 2)cell=(2, 3) neighbor=(3, 2)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(3, 2)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(3, 2)
(1, 3)cell=(2, 3) neighbor=(1, 3)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(1, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(1, 3)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 3) neighbor=(1, 3)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(2, 6)
return { cell=(2, 6)
for dx in [-1, 0, 1]cell=(2, 6)
return { cell=(2, 6)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(2, 6)
return { cell=(2, 6)
for dx in [-1, 0, 1]cell=(2, 6)
for dy in [-1, 0, 1]cell=(2, 6) dx=-1
return { cell=(2, 6) dx=-1
for dy in [-1, 0, 1]cell=(2, 6) dx=-1
if (dx, dy) != (0, 0)cell=(2, 6) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(2, 6) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(2, 6) dx=-1 dy=-1
return { cell=(2, 6) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(2, 6) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(2, 6) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(2, 6) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(2, 6) dx=-1 dy=0
return { cell=(2, 6) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(2, 6) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(2, 6) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(2, 6) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(2, 6) dx=-1 dy=1
return { cell=(2, 6) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(2, 6) dx=-1 dy=1
return { cell=(2, 6) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(2, 6) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(2, 6) dx=0 dy=1
return { cell=(2, 6) dx=0 dy=1
for dy in [-1, 0, 1]cell=(2, 6) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(2, 6) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(2, 6) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(2, 6) dx=0 dy=-1
return { cell=(2, 6) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(2, 6) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(2, 6) dx=0 dy=0
return { cell=(2, 6) dx=0 dy=0
for dy in [-1, 0, 1]cell=(2, 6) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(2, 6) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(2, 6) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(2, 6) dx=0 dy=1
return { cell=(2, 6) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(2, 6) dx=0 dy=1
return { cell=(2, 6) dx=0 dy=1
for dx in [-1, 0, 1]cell=(2, 6) dx=0 dy=1
for dy in [-1, 0, 1]cell=(2, 6) dx=1 dy=1
return { cell=(2, 6) dx=1 dy=1
for dy in [-1, 0, 1]cell=(2, 6) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(2, 6) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(2, 6) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(2, 6) dx=1 dy=-1
return { cell=(2, 6) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(2, 6) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(2, 6) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(2, 6) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(2, 6) dx=1 dy=0
return { cell=(2, 6) dx=1 dy=0
for dy in [-1, 0, 1]cell=(2, 6) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(2, 6) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(2, 6) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(2, 6) dx=1 dy=1
return { cell=(2, 6) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(2, 6) dx=1 dy=1
return { cell=(2, 6) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(2, 6) dx=1 dy=1
{(2, 7), (1, 5), (3, 7), (1, 7), (3, 6), (1, 6), (2, 5), (3, 5)} cell=(2, 6) dx=1 dy=1
{(2, 7), (1, 5), (3, 7), (1, 7), (3, 6), (1, 6), (2, 5), (3, 5)} cell=(2, 6)
(2, 7)cell=(2, 6) neighbor=(2, 7)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(2, 7)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(2, 7)
(1, 5)cell=(2, 6) neighbor=(1, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(1, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(1, 5)
(3, 7)cell=(2, 6) neighbor=(3, 7)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(3, 7)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(3, 7)
(1, 7)cell=(2, 6) neighbor=(1, 7)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(1, 7)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(1, 7)
(3, 6)cell=(2, 6) neighbor=(3, 6)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(3, 6)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(3, 6)
(1, 6)cell=(2, 6) neighbor=(1, 6)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(1, 6)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(1, 6)
(2, 5)cell=(2, 6) neighbor=(2, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(2, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(2, 5)
(3, 5)cell=(2, 6) neighbor=(3, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(3, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(3, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(2, 6) neighbor=(3, 5)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(6, 0)
return { cell=(6, 0)
for dx in [-1, 0, 1]cell=(6, 0)
return { cell=(6, 0)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(6, 0)
return { cell=(6, 0)
for dx in [-1, 0, 1]cell=(6, 0)
for dy in [-1, 0, 1]cell=(6, 0) dx=-1
return { cell=(6, 0) dx=-1
for dy in [-1, 0, 1]cell=(6, 0) dx=-1
if (dx, dy) != (0, 0)cell=(6, 0) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(6, 0) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(6, 0) dx=-1 dy=-1
return { cell=(6, 0) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(6, 0) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(6, 0) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(6, 0) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(6, 0) dx=-1 dy=0
return { cell=(6, 0) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(6, 0) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(6, 0) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(6, 0) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(6, 0) dx=-1 dy=1
return { cell=(6, 0) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(6, 0) dx=-1 dy=1
return { cell=(6, 0) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(6, 0) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(6, 0) dx=0 dy=1
return { cell=(6, 0) dx=0 dy=1
for dy in [-1, 0, 1]cell=(6, 0) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(6, 0) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(6, 0) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(6, 0) dx=0 dy=-1
return { cell=(6, 0) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(6, 0) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(6, 0) dx=0 dy=0
return { cell=(6, 0) dx=0 dy=0
for dy in [-1, 0, 1]cell=(6, 0) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(6, 0) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(6, 0) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(6, 0) dx=0 dy=1
return { cell=(6, 0) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(6, 0) dx=0 dy=1
return { cell=(6, 0) dx=0 dy=1
for dx in [-1, 0, 1]cell=(6, 0) dx=0 dy=1
for dy in [-1, 0, 1]cell=(6, 0) dx=1 dy=1
return { cell=(6, 0) dx=1 dy=1
for dy in [-1, 0, 1]cell=(6, 0) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(6, 0) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(6, 0) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(6, 0) dx=1 dy=-1
return { cell=(6, 0) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(6, 0) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(6, 0) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(6, 0) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(6, 0) dx=1 dy=0
return { cell=(6, 0) dx=1 dy=0
for dy in [-1, 0, 1]cell=(6, 0) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(6, 0) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(6, 0) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(6, 0) dx=1 dy=1
return { cell=(6, 0) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(6, 0) dx=1 dy=1
return { cell=(6, 0) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(6, 0) dx=1 dy=1
{(7, -1), (7, 1), (6, 1), (5, -1), (7, 0), (6, -1), (5, 1), (5, 0)} cell=(6, 0) dx=1 dy=1
{(7, -1), (7, 1), (6, 1), (5, -1), (7, 0), (6, -1), (5, 1), (5, 0)} cell=(6, 0)
(7, -1)cell=(6, 0) neighbor=(7, -1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(7, -1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(7, -1)
(7, 1)cell=(6, 0) neighbor=(7, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(7, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(7, 1)
(6, 1)cell=(6, 0) neighbor=(6, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(6, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(6, 1)
(5, -1)cell=(6, 0) neighbor=(5, -1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(5, -1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(5, -1)
(7, 0)cell=(6, 0) neighbor=(7, 0)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(7, 0)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(7, 0)
(6, -1)cell=(6, 0) neighbor=(6, -1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(6, -1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(6, -1)
(5, 1)cell=(6, 0) neighbor=(5, 1)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(5, 1)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(5, 1)
(5, 0)cell=(6, 0) neighbor=(5, 0)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(5, 0)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(5, 0)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(6, 0) neighbor=(5, 0)
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
def neighbors(cell):cell=(7, 5)
return { cell=(7, 5)
for dx in [-1, 0, 1]cell=(7, 5)
return { cell=(7, 5)
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
100: . . . . . . . . . . . . . . .
101: . . . . . . . . . . . . . . .
102:
return { cell=(7, 5)
return { cell=(7, 5)
for dx in [-1, 0, 1]cell=(7, 5)
for dy in [-1, 0, 1]cell=(7, 5) dx=-1
return { cell=(7, 5) dx=-1
for dy in [-1, 0, 1]cell=(7, 5) dx=-1
if (dx, dy) != (0, 0)cell=(7, 5) dx=-1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(7, 5) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(7, 5) dx=-1 dy=-1
return { cell=(7, 5) dx=-1 dy=-1
for dy in [-1, 0, 1]cell=(7, 5) dx=-1 dy=-1
if (dx, dy) != (0, 0)cell=(7, 5) dx=-1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(7, 5) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(7, 5) dx=-1 dy=0
return { cell=(7, 5) dx=-1 dy=0
for dy in [-1, 0, 1]cell=(7, 5) dx=-1 dy=0
if (dx, dy) != (0, 0)cell=(7, 5) dx=-1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(7, 5) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(7, 5) dx=-1 dy=1
return { cell=(7, 5) dx=-1 dy=1
if (dx, dy) != (0, 0)cell=(7, 5) dx=-1 dy=1
return { cell=(7, 5) dx=-1 dy=1
for dx in [-1, 0, 1]cell=(7, 5) dx=-1 dy=1
for dy in [-1, 0, 1]cell=(7, 5) dx=0 dy=1
return { cell=(7, 5) dx=0 dy=1
for dy in [-1, 0, 1]cell=(7, 5) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(7, 5) dx=0 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(7, 5) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(7, 5) dx=0 dy=-1
return { cell=(7, 5) dx=0 dy=-1
for dy in [-1, 0, 1]cell=(7, 5) dx=0 dy=-1
if (dx, dy) != (0, 0)cell=(7, 5) dx=0 dy=0
return { cell=(7, 5) dx=0 dy=0
for dy in [-1, 0, 1]cell=(7, 5) dx=0 dy=0
if (dx, dy) != (0, 0)cell=(7, 5) dx=0 dy=1
(cell[0] + dx, cell[1] + dy)cell=(7, 5) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(7, 5) dx=0 dy=1
return { cell=(7, 5) dx=0 dy=1
if (dx, dy) != (0, 0)cell=(7, 5) dx=0 dy=1
return { cell=(7, 5) dx=0 dy=1
for dx in [-1, 0, 1]cell=(7, 5) dx=0 dy=1
for dy in [-1, 0, 1]cell=(7, 5) dx=1 dy=1
return { cell=(7, 5) dx=1 dy=1
for dy in [-1, 0, 1]cell=(7, 5) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(7, 5) dx=1 dy=-1
(cell[0] + dx, cell[1] + dy)cell=(7, 5) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(7, 5) dx=1 dy=-1
return { cell=(7, 5) dx=1 dy=-1
for dy in [-1, 0, 1]cell=(7, 5) dx=1 dy=-1
if (dx, dy) != (0, 0)cell=(7, 5) dx=1 dy=0
(cell[0] + dx, cell[1] + dy)cell=(7, 5) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(7, 5) dx=1 dy=0
return { cell=(7, 5) dx=1 dy=0
for dy in [-1, 0, 1]cell=(7, 5) dx=1 dy=0
if (dx, dy) != (0, 0)cell=(7, 5) dx=1 dy=1
(cell[0] + dx, cell[1] + dy)cell=(7, 5) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(7, 5) dx=1 dy=1
return { cell=(7, 5) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(7, 5) dx=1 dy=1
return { cell=(7, 5) dx=1 dy=1
if (dx, dy) != (0, 0)cell=(7, 5) dx=1 dy=1
{(7, 4), (8, 4), (6, 5), (6, 4), (7, 6), (8, 6), (6, 6), (8, 5)} cell=(7, 5) dx=1 dy=1
{(7, 4), (8, 4), (6, 5), (6, 4), (7, 6), (8, 6), (6, 6), (8, 5)} cell=(7, 5)
(7, 4)cell=(7, 5) neighbor=(7, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(7, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(7, 4)
(8, 4)cell=(7, 5) neighbor=(8, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(8, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(8, 4)
(6, 5)cell=(7, 5) neighbor=(6, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(6, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(6, 5)
(6, 4)cell=(7, 5) neighbor=(6, 4)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(6, 4)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(6, 4)
(7, 6)cell=(7, 5) neighbor=(7, 6)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(7, 6)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(7, 6)
(8, 6)cell=(7, 5) neighbor=(8, 6)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(8, 6)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(8, 6)
(6, 6)cell=(7, 5) neighbor=(6, 6)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(6, 6)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(6, 6)
(8, 5)cell=(7, 5) neighbor=(8, 5)
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
92: @ . . . . . . . . . . . . . .
93: @ @ . . . . . . . . . . . . .
94: . . . . . . . . . . . . . . .
95: . . . . . . . . . . . . . . .
96: . . . . . . . . . . . . . . .
97: . . . . . . . . . . . . . . .
98: . . . . . . . . . . . . . . .
99: . . . . . . . . . . . . . . .
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(8, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(8, 5)
return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))cell=(7, 5) neighbor=(8, 5)
Nonecell=(7, 5) neighbor=(8, 5)
if kwds:self=<too long> kwds={}
Noneself=<too long> kwds={}
Noneself=<too long> kwds={}
Counter({(3, 2): 4, (7, 1): 4, (3, 3): 4, (2, 1): 3, (2, 2): 3, (4, 1): 3, (4, 3): 3, (7, 0): 3, (1, 2): 3, (3, 1): 3, (1, 3): 3, (2, 5): 3, (5, 1): 3, (4, 2): 2, (4, 4): 2, (6, 5): 2, (6, 4): 2, (4, 5): 2, (5, 3): 2, (7, -1): 2, (8, 1): 2, (9, 1): 2, (7, 7): 2, (8, 7): 2, (7, 6): 2, (9, 7): 2, (8, 5): 2, (2, 3): 2, (2, 7): 2, (1, 5): 2, (1, 7): 2, (2, 6): 2, (5, 2): 2, (9, 2): 2, (8, 3): 2, (7, 2): 2, (8, 9): 2, (7, 8): 2, (5, 0): 2, (2, 4): 2, (3, 4): 2, (3, 6): 2, (8, 4): 2, (1, 4): 2, (4, 0): 1, (2, 0): 1, (3, 0): 1, (5, 5): 1, (6, 3): 1, (9, 0): 1, (8, -1): 1, (9, -1): 1, (9, 6): 1, (9, 5): 1, (7, 5): 1, (1, 1): 1, (0, 7): 1, (0, 6): 1, (0, 5): 1, (9, 3): 1, (7, 3): 1, (9, 9): 1, (7, 9): 1, (9, 8): 1, (6, 2): 1, (6, 0): 1, (8, 8): 1, (7, 10): 1, (6, 8): 1, (8, 10): 1, (6, 10): 1, (6, 9): 1, (4, 6): 1, (10, 4): 1, (10, 3): 1, (8, 2): 1, (10, 2): 1, (9, 4): 1, (0, 4): 1, (-1, 4): 1, (0, 2): 1, (-1, 3): 1, (-1, 2): 1, (3, 7): 1, (1, 6): 1, (3, 5): 1, (6, 1): 1, (5, -1): 1, (6, -1): 1, (7, 4): 1, (8, 6): 1, (6, 6): 1}) alive_cells=<too long>
return { alive_cells=<too long>
18:
19:
20: def next_generation(alive_cells):
21: return {
22: cell
23: for cell, count in neighbor_counts(alive_cells).items()
24: if count == 3 or (cell in alive_cells and count == 2)
25: }
26:
27: def neighbor_counts(alive_cells):
28: """A Counter of the number of live neighbors for each cell."""
29: return Counter(neighbor for cell in alive_cells for neighbor in neighbors(cell))
30:
31: def neighbors(cell):
32: return {
33: (cell[0] + dx, cell[1] + dy)
34: for dx in [-1, 0, 1]
35: for dy in [-1, 0, 1]
36: if (dx, dy) != (0, 0)
37: }
38:
39: def make_random_world(size, alive_probability=0.2):
40: # Create a size x size world where each cell has a probability of alive_probability to be alive
41: return {(x, y) for x in range(size) for y in range(size) if random.random() < alive_probability}
42:
43: LIVE = '@'
44: EMPTY = '.'
45: PAD = ' '
46: def picture(world, Xs: range, Ys: range) -> str:
47: """Return a picture of the world: a grid of characters representing the cells in this window."""
48: def row(y): return PAD.join(LIVE if (x, y) in world else EMPTY for x in Xs)
49: return '\n'.join(row(y) for y in Ys)
50:
51:
52: world = make_random_world(10, 0.2)
53:
54: sys.path.append('/Users/barisozmen/development/github/barisozmen')
55: print(sys.path)
56: from stackobserver import StackObserver
57:
58: with StackObserver():
59: for _ in range(1):
60: print(f'Generation {_}')
61: print(picture(world, range(15), range(15)))
62: world = next_generation(world)
63: print('\n')
64:
65:
66: """ Output after running `python3 conways_game_of_life.py`
67:
68: Generation 0
69: . . . . . . . . . . . . . . .
70: . . . . . . . . . . . . . . .
71: . . @ . @ . . . @ . . . . . .
72: . @ . @ . . @ . @ . . . . . .
73: @ . . @ . . . @ . @ . . . . .
74: @ . . . . . . . . . . . . . .
75: @ @ . . . . . . . . . . . . .
76: . . . @ . . . . . . . . . . .
77: . . . . @ . . . . . . . . . .
78: . . . . . . @ . . @ . . . . .
79: . . . . . . . . . . . . . . .
80: . . . . . . . . . . . . . . .
81: . . . . . . . . . . . . . . .
82: . . . . . . . . . . . . . . .
83: . . . . . . . . . . . . . . .
84:
85:
86: Generation 1
87: . . . . . . . . . . . . . . .
88: . . . . . . . . . . . . . . .
89: . . @ @ . . . @ . . . . . . .
90: . @ . @ @ . . . @ @ . . . . .
91: @ @ @ . . . . @ @ . . . . . .
return { alive_cells=<too long>
return { alive_cells=<too long>
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long>
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(4, 0) count=1
return { alive_cells=<too long> cell=(4, 0) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(4, 0) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 1) count=3
cellalive_cells=<too long> cell=(2, 1) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 1) count=3
return { alive_cells=<too long> cell=(2, 1) count=3
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(2, 1) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 0) count=1
return { alive_cells=<too long> cell=(2, 0) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(2, 0) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(4, 2) count=2
cellalive_cells=<too long> cell=(4, 2) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(4, 2) count=2
return { alive_cells=<too long> cell=(4, 2) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(4, 2) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(3, 0) count=1
return { alive_cells=<too long> cell=(3, 0) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(3, 0) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 2) count=3
cellalive_cells=<too long> cell=(2, 2) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 2) count=3
return { alive_cells=<too long> cell=(2, 2) count=3
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(2, 2) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(3, 2) count=4
return { alive_cells=<too long> cell=(3, 2) count=4
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(3, 2) count=4
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(4, 1) count=3
cellalive_cells=<too long> cell=(4, 1) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(4, 1) count=3
return { alive_cells=<too long> cell=(4, 1) count=3
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(4, 1) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(4, 4) count=2
return { alive_cells=<too long> cell=(4, 4) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(4, 4) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(5, 5) count=1
return { alive_cells=<too long> cell=(5, 5) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(5, 5) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(6, 5) count=2
return { alive_cells=<too long> cell=(6, 5) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(6, 5) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(4, 3) count=3
cellalive_cells=<too long> cell=(4, 3) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(4, 3) count=3
return { alive_cells=<too long> cell=(4, 3) count=3
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(4, 3) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(6, 4) count=2
return { alive_cells=<too long> cell=(6, 4) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(6, 4) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(4, 5) count=2
return { alive_cells=<too long> cell=(4, 5) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(4, 5) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(5, 3) count=2
return { alive_cells=<too long> cell=(5, 3) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(5, 3) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(6, 3) count=1
return { alive_cells=<too long> cell=(6, 3) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(6, 3) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, -1) count=2
return { alive_cells=<too long> cell=(7, -1) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(7, -1) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(9, 0) count=1
return { alive_cells=<too long> cell=(9, 0) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(9, 0) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(8, -1) count=1
return { alive_cells=<too long> cell=(8, -1) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(8, -1) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, 1) count=4
return { alive_cells=<too long> cell=(7, 1) count=4
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(7, 1) count=4
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(8, 1) count=2
return { alive_cells=<too long> cell=(8, 1) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(8, 1) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, 0) count=3
cellalive_cells=<too long> cell=(7, 0) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, 0) count=3
return { alive_cells=<too long> cell=(7, 0) count=3
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(7, 0) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(9, -1) count=1
return { alive_cells=<too long> cell=(9, -1) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(9, -1) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(9, 1) count=2
return { alive_cells=<too long> cell=(9, 1) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(9, 1) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, 7) count=2
return { alive_cells=<too long> cell=(7, 7) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(7, 7) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(8, 7) count=2
return { alive_cells=<too long> cell=(8, 7) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(8, 7) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(9, 6) count=1
return { alive_cells=<too long> cell=(9, 6) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(9, 6) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(9, 5) count=1
return { alive_cells=<too long> cell=(9, 5) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(9, 5) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, 6) count=2
return { alive_cells=<too long> cell=(7, 6) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(7, 6) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, 5) count=1
return { alive_cells=<too long> cell=(7, 5) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(7, 5) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(9, 7) count=2
return { alive_cells=<too long> cell=(9, 7) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(9, 7) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(8, 5) count=2
return { alive_cells=<too long> cell=(8, 5) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(8, 5) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(1, 2) count=3
cellalive_cells=<too long> cell=(1, 2) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(1, 2) count=3
return { alive_cells=<too long> cell=(1, 2) count=3
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(1, 2) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(3, 1) count=3
cellalive_cells=<too long> cell=(3, 1) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(3, 1) count=3
return { alive_cells=<too long> cell=(3, 1) count=3
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(3, 1) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(1, 1) count=1
return { alive_cells=<too long> cell=(1, 1) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(1, 1) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 3) count=2
cellalive_cells=<too long> cell=(2, 3) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 3) count=2
return { alive_cells=<too long> cell=(2, 3) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(2, 3) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(3, 3) count=4
return { alive_cells=<too long> cell=(3, 3) count=4
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(3, 3) count=4
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(1, 3) count=3
cellalive_cells=<too long> cell=(1, 3) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(1, 3) count=3
return { alive_cells=<too long> cell=(1, 3) count=3
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(1, 3) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(0, 7) count=1
return { alive_cells=<too long> cell=(0, 7) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(0, 7) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 7) count=2
return { alive_cells=<too long> cell=(2, 7) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(2, 7) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(1, 5) count=2
return { alive_cells=<too long> cell=(1, 5) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(1, 5) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(0, 6) count=1
return { alive_cells=<too long> cell=(0, 6) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(0, 6) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(1, 7) count=2
return { alive_cells=<too long> cell=(1, 7) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(1, 7) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 6) count=2
cellalive_cells=<too long> cell=(2, 6) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 6) count=2
return { alive_cells=<too long> cell=(2, 6) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(2, 6) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(0, 5) count=1
return { alive_cells=<too long> cell=(0, 5) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(0, 5) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 5) count=3
cellalive_cells=<too long> cell=(2, 5) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 5) count=3
return { alive_cells=<too long> cell=(2, 5) count=3
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(2, 5) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(5, 1) count=3
cellalive_cells=<too long> cell=(5, 1) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(5, 1) count=3
return { alive_cells=<too long> cell=(5, 1) count=3
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(5, 1) count=3
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(5, 2) count=2
return { alive_cells=<too long> cell=(5, 2) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(5, 2) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(9, 3) count=1
return { alive_cells=<too long> cell=(9, 3) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(9, 3) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(9, 2) count=2
return { alive_cells=<too long> cell=(9, 2) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(9, 2) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, 3) count=1
return { alive_cells=<too long> cell=(7, 3) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(7, 3) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(8, 3) count=2
return { alive_cells=<too long> cell=(8, 3) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(8, 3) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, 2) count=2
return { alive_cells=<too long> cell=(7, 2) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(7, 2) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(9, 9) count=1
return { alive_cells=<too long> cell=(9, 9) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(9, 9) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, 9) count=1
return { alive_cells=<too long> cell=(7, 9) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(7, 9) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(8, 9) count=2
return { alive_cells=<too long> cell=(8, 9) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(8, 9) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(9, 8) count=1
return { alive_cells=<too long> cell=(9, 8) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(9, 8) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, 8) count=2
return { alive_cells=<too long> cell=(7, 8) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(7, 8) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(6, 2) count=1
return { alive_cells=<too long> cell=(6, 2) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(6, 2) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(5, 0) count=2
return { alive_cells=<too long> cell=(5, 0) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(5, 0) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(6, 0) count=1
return { alive_cells=<too long> cell=(6, 0) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(6, 0) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(8, 8) count=1
return { alive_cells=<too long> cell=(8, 8) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(8, 8) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, 10) count=1
return { alive_cells=<too long> cell=(7, 10) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(7, 10) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(6, 8) count=1
return { alive_cells=<too long> cell=(6, 8) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(6, 8) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(8, 10) count=1
return { alive_cells=<too long> cell=(8, 10) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(8, 10) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(6, 10) count=1
return { alive_cells=<too long> cell=(6, 10) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(6, 10) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(6, 9) count=1
return { alive_cells=<too long> cell=(6, 9) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(6, 9) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(2, 4) count=2
return { alive_cells=<too long> cell=(2, 4) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(2, 4) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(3, 4) count=2
return { alive_cells=<too long> cell=(3, 4) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(3, 4) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(4, 6) count=1
return { alive_cells=<too long> cell=(4, 6) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(4, 6) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(3, 6) count=2
return { alive_cells=<too long> cell=(3, 6) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(3, 6) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(8, 4) count=2
return { alive_cells=<too long> cell=(8, 4) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(8, 4) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(10, 4) count=1
return { alive_cells=<too long> cell=(10, 4) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(10, 4) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(10, 3) count=1
return { alive_cells=<too long> cell=(10, 3) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(10, 3) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(8, 2) count=1
return { alive_cells=<too long> cell=(8, 2) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(8, 2) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(10, 2) count=1
return { alive_cells=<too long> cell=(10, 2) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(10, 2) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(9, 4) count=1
return { alive_cells=<too long> cell=(9, 4) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(9, 4) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(0, 4) count=1
return { alive_cells=<too long> cell=(0, 4) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(0, 4) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(-1, 4) count=1
return { alive_cells=<too long> cell=(-1, 4) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(-1, 4) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(1, 4) count=2
return { alive_cells=<too long> cell=(1, 4) count=2
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(1, 4) count=2
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(0, 2) count=1
return { alive_cells=<too long> cell=(0, 2) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(0, 2) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(-1, 3) count=1
return { alive_cells=<too long> cell=(-1, 3) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(-1, 3) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(-1, 2) count=1
return { alive_cells=<too long> cell=(-1, 2) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(-1, 2) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(3, 7) count=1
return { alive_cells=<too long> cell=(3, 7) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(3, 7) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(1, 6) count=1
return { alive_cells=<too long> cell=(1, 6) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(1, 6) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(3, 5) count=1
return { alive_cells=<too long> cell=(3, 5) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(3, 5) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(6, 1) count=1
return { alive_cells=<too long> cell=(6, 1) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(6, 1) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(5, -1) count=1
return { alive_cells=<too long> cell=(5, -1) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(5, -1) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(6, -1) count=1
return { alive_cells=<too long> cell=(6, -1) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(6, -1) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(7, 4) count=1
return { alive_cells=<too long> cell=(7, 4) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(7, 4) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(8, 6) count=1
return { alive_cells=<too long> cell=(8, 6) count=1
for cell, count in neighbor_counts(alive_cells).items()alive_cells=<too long> cell=(8, 6) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(6, 6) count=1
return { alive_cells=<too long> cell=(6, 6) count=1
if count == 3 or (cell in alive_cells and count == 2)alive_cells=<too long> cell=(6, 6) count=1
{(1, 3), (1, 2), (2, 1), (4, 3), (3, 1), (7, 0), (5, 1), (4, 2), (2, 3), (2, 6), (2, 2), (2, 5), (4, 1)} alive_cells=<too long> cell=(6, 6) count=1
{(1, 3), (1, 2), (2, 1), (4, 3), (3, 1), (7, 0), (5, 1), (4, 2), (2, 3), (2, 6), (2, 2), (2, 5), (4, 1)} alive_cells=<too long>